import apiMixin from '@/mixin/apiMixin';
import taskMixin from '@/mixin/taskMixin';

export default {
    mixins: [apiMixin,taskMixin],
    data() {
        return {
            tableData: [],
            listNums: 0,
            loading: false,
            searchText: '',
            searchTypeList: [
                { value: "transaction_id", name: "充值结果检查" },
                { value: "file_id", name: "视频转码" },
                { value: "task_id", name: "任务查询" },
                { value: "task_accept_id", name: "任务领取自动审核" },
                { value: "task_arbitration_id", name: "仲裁复审未上传资料自动审判" }
            ],
            searchType: 'transaction_id',
            status: [
                {
                    text: '等待执行',
                    value: '0'
                },
                {
                    text: '执行成功',
                    value: '1'
                },
                {
                    text: '不执行',
                    value: '2'
                },
            ]
        }
    },
    mounted() {
        if (this.filterStatus == 0 || this.filterStatu) {
            this.$refs.filterTable.columns[4].filteredValue = this.filterStatus.split(',');
        }
        this.init();
    },
    methods: {  
        init() {
            this.getPlanListApi(); 
        },
        getPlanListApi(page) {
            let _self = this;
            this.comResquest(this.request.getPlanList,(res)=>{
                console.log(res);
                let { count,result } = res;
                _self.listNums = count;
                _self.tableData = result;
                _self.updateRoutePar(page);
            },{
                page,
                type: this.searchType,
                keyword: this.searchText,
                status: this.filterStatus || 0,
                load: true,
            })
        },
        executePlanApi(excuteIndex,type) {
            let excuteObj = JSON.parse(JSON.stringify(this.tableData[excuteIndex]));
            let _self = this;
            this.comResquest(this.request.executePlan,(res)=>{
                _self.$message.success("执行成功");
                excuteObj.status = 1;
                _self.$set(_self.tableData,excuteIndex,excuteObj);
            },{
                task_id: excuteObj.id,
                status: type,
                load: true,
            })
        },
        searchWill() {
            this.getPlanListApi(1);
        },
        changePage(page) {
            page = page || 1;
            this.getPlanListApi(page);
        },
        handleFilter(e) {
            this.filterStatus = e.status.join(',');
            this.getPlanListApi(1);
        }
    },
}